import { useState } from "react";

const useAccordion = (initValue = "") => {
  const [active, setActive] = useState(initValue);

  const toggleActive = (id: string) => {
    if (active === id) {
      setActive("");
    } else {
      setActive(id);
    }
  };

  return { active, toggleActive };
};

export default useAccordion;
